package com.zz.cinema.domain;

import java.util.Date;
import java.util.UUID;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name = "TS_RECORD")
public class TS_Record {
	
	/**
	 * create sequence SEQ_TS_RECORD 
	 * minvalue 100,000,000 
	 * maxvalue 199,999,999
	 * start with 100,000,000
	 * increment by 1
	 * cache 20;
	 */
	@Id
	@GeneratedValue(generator = "sequenceGenerator_TS_RECORD", strategy = GenerationType.SEQUENCE)
	@SequenceGenerator(name = "sequenceGenerator_TS_RECORD", sequenceName = "SEQ_TS_RECORD", initialValue = 100000000, allocationSize = 1)
	private int recordId;
	
	private String uuid;
	
	private double discount;
	
	private String seatNumner;
	
	private Date buyTime;
	
	@ManyToOne(cascade = CascadeType.ALL, targetEntity = TS_Customer.class, fetch = FetchType.LAZY)
	@JoinColumn(name = "customerId", referencedColumnName = "customerId")
	private TS_Customer customer;
	
	@ManyToOne(cascade = CascadeType.ALL, targetEntity = TS_ItemON.class, fetch = FetchType.LAZY)
	@JoinColumn(name = "itemONId", referencedColumnName = "itemONId")
	private TS_ItemON itemON;

	public TS_Record() {
		super();
		this.uuid = UUID.randomUUID().toString().toUpperCase();
	}

	public TS_Record(double discount, String seatNumner, Date buyTime, TS_Customer customer,
			TS_ItemON itemON) {
		super();
		this.uuid = UUID.randomUUID().toString().toUpperCase();
		this.discount = discount;
		this.seatNumner = seatNumner;
		this.buyTime = buyTime;
		this.customer = customer;
		this.itemON = itemON;
	}

	public int getRecordId() {
		return recordId;
	}

	public void setRecordId(int recordId) {
		this.recordId = recordId;
	}

	public String getUuid() {
		return uuid;
	}

	public void setUuid(String uuid) {
		this.uuid = uuid;
	}

	public double getDiscount() {
		return discount;
	}

	public void setDiscount(double discount) {
		this.discount = discount;
	}

	public String getSeatNumner() {
		return seatNumner;
	}

	public void setSeatNumner(String seatNumner) {
		this.seatNumner = seatNumner;
	}

	public Date getBuyTime() {
		return buyTime;
	}

	public void setBuyTime(Date buyTime) {
		this.buyTime = buyTime;
	}

	public TS_Customer getCustomer() {
		return customer;
	}

	public void setCustomer(TS_Customer customer) {
		this.customer = customer;
	}

	public TS_ItemON getItemON() {
		return itemON;
	}

	public void setItemON(TS_ItemON itemON) {
		this.itemON = itemON;
	}

	@Override
	public String toString() {
		return "TS_Record [recordId=" + recordId + ", uuid=" + uuid + ", discount=" + discount + ", seatNumner="
				+ seatNumner + ", buyTime=" + buyTime + ", customer=" + customer + ", itemON=" + itemON + "]";
	}

}
